package com.qian.ddj.register.controller;

import com.qian.api.ddj.model.BusinessGroup;
import com.qian.api.ddj.model.Channel;
import com.qian.api.ddj.model.StatusDict;
import com.qian.api.ddj.service.IBusinessGroupService;
import com.qian.api.ddj.service.IChannelService;
import com.yaowk.api.common.PageReq;
import com.yaowk.api.common.PageResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ddj/register")
@Api(tags = "报件接口")
public class RegisterController {

    @Autowired
    private IChannelService channelService;
    @Autowired
    private IBusinessGroupService businessGroupService;

    @ApiOperation("通道列表")
    @GetMapping("/channel")
    public PageResp<Channel> channelList(PageReq pageReq) {
        Channel channel = new Channel();
        channel.setRegister(StatusDict.NORMAL);
        PageResp<Channel> page = channelService.findAll(channel, pageReq);
        return page;
    }

    @ApiOperation("商户组列表")
    @GetMapping("/businessGroup/{id}")
    public PageResp<BusinessGroup> groupList(PageReq pageReq, @PathVariable Integer id) {
        BusinessGroup businessGroup = new BusinessGroup();
        businessGroup.setChannelId(id);
        PageResp<BusinessGroup> page = businessGroupService.findAll(businessGroup, pageReq);
        return page;
    }
}
